package com.young.filesystem;

import javax.servlet.MultipartConfigElement;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.util.unit.DataSize;

@ComponentScan({"com.young"})
@MapperScan("com.young.filesystem.mapper")
@EnableDiscoveryClient
@SpringBootApplication
public class FileApplication {
  public static void main(String[] args) {
    SpringApplication.run(FileApplication.class, args);
  }

  @Bean
  public MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    factory.setMaxFileSize(DataSize.ofMegabytes(20));
    factory.setMaxRequestSize(DataSize.ofMegabytes(30));
    factory.setLocation("/data/upload_tmp");
    return factory.createMultipartConfig();
  }
}
